package com.example.chenfenweb.controller;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RedirectServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        // 设置状态码为302表示临时重定向，或者使用301表示永久重定向
        response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
        // 设置重定向的目标URL
        response.setHeader("Location", "http://www.new-url.com");
    }
}